package com.example.arithmeticleetcode.learnArithmetic.quque;

/**
 * @program: arithmetic-leetcode
 * @description: 双端队列
 * @author: FangZhen
 * @create: 2020-08-20 18:25
 **/
public class DeQuque<E> {

    private List<E> list = new LinkedList<>();

    public void clear() {
        list.clear();
    }

    public int size() {
        return list.size();
    }

    public boolean isEmpty() {
        return list.isEmpty();
    }

    public void enQuqueRear(E element) {
        list.add(element);
    }

    public E deQuqueFront() {
        return list.remove(0);
    }

    public void enQuqueFront(E element) {
        list.add(0, element);
    }

    public E deQuqueRear() {
        return list.remove(list.size() - 1);
    }

    public E front() {
        return list.get(0);
    }

    public E rear() {
        return list.get(list.size() - 1);
    }
}
